package com.framework;

import com.ulisesbocchio.jasyptspringboot.environment.StandardEncryptableEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class OauthApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = new SpringApplicationBuilder()
                .environment(new StandardEncryptableEnvironment())
                .sources(OauthApplication.class).run(args);
        Environment environment = context.getBean(Environment.class);
        String port = environment.getProperty("local.server.port");
        Logger logger = LoggerFactory.getLogger(OauthApplication.class );
        logger.info( "--------------- {} is success! port: {}---------------", OauthApplication.class.getSimpleName(), port);

    }
    public static String secret() {
        //用户密码
        String password = "admin";
        //密码加密
        BCryptPasswordEncoder passwordEncoder=new BCryptPasswordEncoder();
        //加密
        String newPassword = passwordEncoder.encode(password);
        return newPassword;
    }
}
